package com.wt.dao;

import com.wt.dao.idao.ITravelDao;
import com.wt.entity.Travel;
import com.wt.mapper.impl.TravelRowMapper;
import com.wt.util.DBHelper;

import java.sql.SQLException;
import java.util.List;

public class TravelDao implements ITravelDao {
    DBHelper<Travel> dbHelper = new DBHelper<>();

    /**
     * 查询
     * @param search 查询关键字
     * @return 查询集合
     * @throws SQLException
     */
    @Override
    public List<Travel> searchTravel(String search) throws SQLException {
        dbHelper.getConnection();
        String sql = "select * " +
                "from area join scenic on area.area_no=scenic.scenic_area " +
                "where area_prairies like ? or area_name like ? or scenic_name like ?";
        List<Travel> travels = dbHelper.executeLike(sql, new TravelRowMapper(),search,search,search);
        dbHelper.closeConnection();
        return travels;
    }
}
